import requests

headers = {
    'authority': 'match.yuanrenxue.cn',
    'accept': 'application/json, text/javascript, */*; q=0.01',
    'accept-language': 'zh-CN,zh;q=0.9',
    'cookie': 'Hm_lvt_c99546cf032aaa5a679230de9a95c7db=1695195854; Hm_lvt_9bcbda9cbf86757998a2339a0437208e=1695195857; no-alert3=true; Hm_lpvt_9bcbda9cbf86757998a2339a0437208e=1695277967; Hm_lpvt_c99546cf032aaa5a679230de9a95c7db=1695277970',
    'referer': 'https://match.yuanrenxue.cn/match/1',
    'sec-ch-ua': '"Google Chrome";v="117", "Not;A=Brand";v="8", "Chromium";v="117"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"macOS"',
    'sec-fetch-dest': 'empty',
    'sec-fetch-mode': 'cors',
    'sec-fetch-site': 'same-origin',
    'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36',
    'x-requested-with': 'XMLHttpRequest',
}

import execjs
aa_list = []
for i in range(1,6):
    aa = execjs.compile(open("./topic_1.js",'r').read())
    aa = aa.eval('get_m()')
    params = (
        ('page', i),
        ('m', aa.replace('丨','\u4E28')),
    )
    response = requests.get('https://match.yuanrenxue.cn/api/match/1', headers=headers, params=params)
    j = response.json()
    print(j)
    [aa_list.append(i['value']) for i in j['data']]
import statistics
print(statistics.mean(aa_list))